package map;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;

public class HashMapTest {
	/**
	 * HashMap contains the value based on key.
	 * it implements the map interface and extends AbstractMap class.
	 * it contains unique element.
	 * it may have one null key and multiple null value.
	 * it maintain no order. 
	 * 
	**/
	public static void main(String[] args) {
		HashMap<Integer, String> hm = new HashMap<Integer,String>();
		//TreeMap<Integer, String> hm = new TreeMap<Integer,String>();
		hm.put(13, "vibhanshu");
		hm.put(15, "praveen");
		hm.put(11, "praveen");
		hm.put(12, "rajeev");
		/*for(Map.Entry m:hm.entrySet()){
			System.out.println(m.getKey()+" "+m.getValue());    -----> By for each method  %%%(usefull)%%%
		}*/
		// ********** By Iterator Method ***************
		
		// step 1 - get a set of the entries 
		Set<?> set = hm.entrySet();   // what does it mean??-----> Set<?>
		
		// step 2 - get an iterator
		Iterator i = set.iterator();
		
		// step 3 - Display the element
		while(i.hasNext()){
			Map.Entry me = (Map.Entry)i.next();
			System.out.println(me.getKey()+" "+me.getValue());
			
		}
		
	}

}
